package com.xianggu.loadBalancing;

import com.xianggu.protocol.URL;

import java.util.List;
import java.util.Random;

public class RandomLoadBalancingStrategy implements LoadBalancingStrategy {
    @Override
    public URL select(List<URL> servers) {
        if (servers == null || servers.isEmpty()) {
            return null;
        }
        Random random = new Random();
        int index = random.nextInt(servers.size());
        return servers.get(index);
    }
}